#include "user_tick.h"
#include "app_can.h"
#include "CAN.h"
#include "app_output.h"
#include "app_input.h"
uint32_t ul_system_tick = 0;

void Main_Tick(void)
{
	ul_system_tick++;
	ul_output_timeout_cnt++;

    if((ul_system_tick%TIME_OUT_50MS) == 0) uc_feed_watch_dog_timeout_flag = 1;			//这个三行代码不能动，不然会造成无法喂狗，CPU会反复复位，后果是变成砖头！！！

	if ((ul_system_tick % TIME_OUT_100MS) == 0)
	{
		if(ul_can_rx_cnt != ul_can_rx_cnt_last) ul_can_rx_cnt_last = ul_can_rx_cnt;
		else ul_can_rx_error_cnt++;
    }
	if((ul_system_tick%gSpeedLedTimeoutCnt) == 0)
	{
		if(gSpeedLEDFlickerTimeoutSn == 1) gSpeedLEDFlickerTimeoutSn = 0;		
		else gSpeedLEDFlickerTimeoutSn = 1;
	}

	if((ul_system_tick % TIME_OUT_1MS) == 0)
	{
	#if (HEM1601_CAN_IO == 1)
		app_can_recv();
	#endif
		output_update();
	}
	else
	{
		input_update();
	#if (HEM1601_CAN_IO == 1)
		app_can_send();
	#endif
        Can_Tx_Fifo();
	}
}
